﻿using MySql.Data.Entity;
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations.Model;
using System.Data.Entity.Migrations.Sql;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Akso.EntityFramework
{
    /// <summary>
    /// 自定义MySQL迁移类，去掉对AlterTableOperation的操作。
    /// </summary>
    public class CustomMySqlMigrationSqlGenerator : MySqlMigrationSqlGenerator
    {
        public override IEnumerable<MigrationStatement> Generate(IEnumerable<MigrationOperation> migrationOperations, string providerManifestToken)
        {
            var statments = new System.Collections.Generic.List<MigrationOperation>();
            foreach (var item in migrationOperations)
            {
                var migration = item as AlterTableOperation;
                if (migration == null)
                {
                    statments.Add(item);
                }
            }
            return base.Generate(statments, providerManifestToken);
        }
    }
}
